<?php
/* jQ Blog theme (v1.1) - a theme for PHP-Fusion v7. Theme author: Sveinung {Sveinungs} Skjerseth, http://yafs.net 
Released as free software without waranties under the Affero GPLv3, see http://www.fsf.org/licensing/licenses/agpl-3.0.html */
if (!defined("IN_FUSION")) { die("Access Denied"); }

define("THEME_BULLET", "");

require_once INCLUDES."theme_functions_include.php";
include LOCALE.LOCALESET."comments.php";
include LOCALE.LOCALESET."ratings.php";

// THEME CONFIG OPTIONS:
$theme_width = "996px"; // Theme width
$u_panel = true; // Display a login-panel for Guests when inside the /forum/. Values: true || false
$com_panel = false; //Include the built-in comments panel. Values: true || false

$url = FUSION_REQUEST;
$fplaces = array(	"/forum/" ); //Hides all side-panels when inside the /forum/ folder
$in_fforum = false;
foreach($fplaces as $place){ if(stristr($url, $place))$in_fforum = true; }

function render_page($license=false) {

	global $settings, $locale, $aidlink, $theme_width, $userdata, $p_data, $in_fforum, $u_panel, $com_panel;

echo "<table cellpadding='0' cellspacing='0' align='center' id='header'>\n<tr>\n<td>\n";

echo "<table cellpadding='0' cellspacing='0' id='main-header' style='width:$theme_width'>\n<tr>\n";

echo"<td id='cont'><a class='cont' href='#content'>".$locale['global_210']."</a></td>\n";

  echo "<td class='whiteheader' style='font-size:9px; text-align: right;' align='right'>
          <ul>\n";
            if(iMEMBER){
						$msg_count = dbcount("(message_id)", DB_MESSAGES, "message_to='".$userdata['user_id']."' AND message_read='0'AND message_folder='0'");
            echo "<li><a href='".BASEDIR."edit_profile.php'>".$locale['global_120']."</a></li>\n
						      <li><a href='".BASEDIR."messages.php'>".$locale['global_121']."";if ($msg_count){echo"&nbsp;<span id='msgcount'>[$msg_count]</span>";}echo"</a></li>\n
						      ".(iADMIN ? "<li><a href='".ADMIN."index.php".$aidlink."' >".$locale['global_123']."</a></li>\n" : "")."
						      <li><a href='".BASEDIR."setuser.php?logout=yes'>".$locale['global_124']."</a></li>\n";
					}else{
						echo "<li><a href='".BASEDIR."login.php'>".$locale['global_104']."</a></li>\n
						".($settings['enable_registration'] ? "<li><a href='".BASEDIR."register.php'>".$locale['global_107']."</a></li>\n" : "");
				  } echo "
           </ul>
        </td>\n";
        
echo "</tr></table>\n";

echo "<table cellpadding='0' cellspacing='0' align='center' style='width:$theme_width'><tr>\n";       

echo "<td>".showbanners()."</td>\n";

echo "</tr></table>\n";
echo "<table cellpadding='0' cellspacing='0' align='center' style='width:$theme_width'><tr>\n";  
	
  echo "<td class='whiteheader' style='text-align: left; margin-bottom:0;'>".showsublinks("");
  echo "</td>\n<td>\n";

  echo " <form name='searchform' method='get' action='".BASEDIR."search.php'>\n";
  echo " <input type='text' name='stext' class='searchbox' maxlength='30' />\n";
  echo " </form>";
  echo "</td>\n</tr></table>";
  
echo "</td></tr></table>\n";
   
   //Content  
echo "<table cellpadding='0' cellspacing='0' width='100%' align='center' id='main-bg' style='width:$theme_width'>\n<tr>\n";
echo "<td valign='top' width='100%'>";

  echo "<table cellspacing='0' cellpadding='0' width='100%' class='tb-bg'>";
  echo "<tr>\n<td class='left-tc'></td><td></td><td align='right' class='right-tc'></td>\n";
  echo "</tr>\n</table>\n";
  
  echo "<table cellspacing='0' cellpadding='0' width='100%' style='background-color:#FFF;border-left:1px solid #8093A6;border-right:1px solid #8093A6;'>\n<tr>\n";                

      if (defined("ADMIN_PANEL")) { echo "<td class='special-c' valign='top'><img src='".THEME."images/s-border.gif' alt='' />".LEFT."</td>"; }
        
      echo "<td id='main' valign='top' width='100%'>"; 
            
          if (iGUEST && $in_fforum && $u_panel) {
          @include THEME."includes/forum_panel_include.php";
          }
      
      echo U_CENTER.CONTENT.L_CENTER."</td>\n";  

    if ((LEFT || RIGHT) && (!$in_fforum) && (!defined("ADMIN_PANEL"))) {
      echo "<td valign='top' style='border-left:1px solid #8093A6;'>
      <table cellspacing='0' cellpadding='0'><tr>\n";
      if (LEFT) { echo "<td class='side-border-left' valign='top'><img src='".THEME."images/s-border.gif' alt='' />".LEFT."</td>";}
      if (RIGHT) { echo "<td id='side-border-right' valign='top'><img src='".THEME."images/s-border.gif' alt='' />".RIGHT."</td>\n";}       
  
        if (LEFT && RIGHT && $com_panel) { echo "</tr><tr><td colspan='2' class='side-border-left' valign='top'>";
                @include THEME."includes/comments_panel_include.php"; echo "</td>\n";
                }
      echo "</tr></table>\n</td>\n";
    }  
    echo "</tr>\n</table>\n";
  echo "<table cellspacing='0' cellpadding='0' width='100%' class='tb-bg'>";
  echo "<tr>\n<td class='left-bc'></td><td></td><td align='right' class='right-bc'></td>\n";
  echo "</tr>\n</table>\n";
  
    	//Footer
	echo "<table cellspacing='0' cellpadding='0' align='center' width='96%' class='tb-bg center' style='margin-top:13px;clear:both;'>";
  echo "<tr>\n<td class='left-tc'></td><td></td><td align='right' class='right-tc'></td>\n";
	echo "</tr><tr><td colspan='3' width='96%' class='center' style='background-color:#FFF;padding:10px;border-left:1px solid #8093A6;border-right:1px solid #8093A6;'>";
  echo "<div class='footernav' style='text-align: center; clear:both;'>".showsublinks("")."</div>\n<br />\n";
  echo "<div style='float:left; width:50%;'>".stripslashes($settings['footer'])."</div>\n";
	echo "<div style='float:right;text-align:right;width:50%;'>\n";
    if (!$license) {echo"".showcopyright()."<br />\n";}
	echo "".sprintf($locale['global_172'], substr((get_microtime() - START_TIME),0,4))."&nbsp;|&nbsp;".showcounter()."&nbsp;";if (!$license) { echo "|&nbsp;<a href='http://yafs.net' target='_blank' title='A theme by Sveinung Skj&aelig;rseth'>jQ Blog</a></div>\n";}
  echo "</td>\n</tr>\n";
  echo "<tr>\n<td class='left-bc'></td><td></td><td align='right' class='right-bc'></td>\n";
  echo "</tr>\n</table>\n";
  
  echo "</td>\n";

  echo "</tr>\n</table>\n";
		
}

function render_news($subject, $news, $info) {

global $locale, $aidlink;

	echo "<h1 class='ncapmain'>".$subject."</h1>\n";
	echo $news."\n";
				if (!isset($_GET['readmore']) && $info['news_ext'] == "y") { echo " <a href='news.php?readmore=".$info['news_id']."'><img src='".THEME."images/readmore.png' alt='' style='vertical-align:middle;border:0px;' /><strong>".$locale['global_072']."...</strong></a><br />";}
      echo "<p class='nfoot'>";
      echo "<img src='".THEME."images/author.gif' alt='' style='vertical-align:middle;border:0px;' /> <a href='profile.php?lookup=".$info['user_id']."'>".$info['user_name']."</a> ".$locale['global_071'].showdate("longdate", $info['news_date']);
        if ($info['news_allow_comments']) { echo " | <img src='".THEME."images/comments.gif' alt='' style='vertical-align:middle;border:0px;' /> <a href='news.php?readmore=".$info['news_id']."'>".$info['news_comments'].($info['news_comments'] == 1 ? $locale['global_073b'] : $locale['global_073'])."</a> |";}
        echo " <a href='print.php?type=N&amp;item_id=".$info['news_id']."'><img src='".THEME."images/printer.gif' alt='".$locale['global_075']."' title='".$locale['global_075']."' style='vertical-align:middle;border:0px;' /></a>";
        if (iADMIN && checkrights("N")) { echo " <a href='".ADMIN."news.php".$aidlink."&amp;action=edit&amp;news_id=".$info['news_id']."'><img src='".IMAGES."edit.gif' alt='".$locale['global_076']."' title='".$locale['global_076']."' style='vertical-align:middle;border:0px;' /></a>\n"; }
      echo "</p>";

}

function render_article($subject, $article, $info) {
	
	echo "<h1 class='ncapmain'>".$subject."</h1>\n";
	echo "".($info['article_breaks'] == "y" ? nl2br($article) : $article)."<br />\n";
	echo "<p class='nfoot'>".articleposter($info," &middot;").articleopts($info,"&middot;").itemoptions("A",$info['article_id'])."</p>";

}

function opentable($title) {

  global $p_data, $locale;
  
    if (file_exists(THEME."images/title/".$p_data['panel_filename'].".png")) {
    $title = "<img class='p-img' src='".THEME."images/title/".$p_data['panel_filename'].".png' alt='' />$title";
    } if  ($title == $locale['c100'] ) {
    $title = "<img class='p-img' src='".THEME."images/title/latest_comments_panel.png' alt='' />".$locale['c100']."";
    } if  ($title == $locale['c102'] ) {
    $title = "<img class='p-img' src='".THEME."images/title/post_comment.png' alt='' />".$locale['c102']."";
    } if  ($title == $locale['r100'] ) {
    $title = "<img class='p-img' src='".THEME."images/title/ratings.png' alt='' />".$locale['r100']."";    
    } else {
    $title = "$title";
    }

	echo "<h2 class='panel'>".$title."</h2>\n";
}

function closetable() {

}

function openside($title, $collapse = false, $state = "on") {

	global $p_data, $panel_collapse; $panel_collapse = $collapse;
	
	if(($p_data['panel_filename'] == "navigation_panel") || ($p_data['panel_filename'] == "css_navigation_panel") || ($p_data['panel_filename'] == "shoutbox_panel")) {
  echo "<div class='special'>\n";
  } 
  else if ($p_data['panel_filename'] == "member_poll_panel") {
  echo "<div class='special-b'>\n";
	}
  else if ($p_data['panel_filename'] == "user_info_panel") {
  echo "<div class='special-c'>\n";
	}  
  else { echo "<div class='normal'>\n";}
	
  if($p_data['panel_filename'] !== "css_navigation_panel"){
	echo "<h3>".$title."</h3>\n";
	}
  	
	if ($collapse == true) {
		$boxname = str_replace(" ", "", $title);
		echo "<div class='p-state'>".panelbutton($state, $boxname)."</div>\n";
	}	
	if ($collapse == true) { echo panelstate($state, $boxname); }

}

function closeside() {
	
	global $panel_collapse;
	
  echo "</div>";
	
  if ($panel_collapse == true) { echo "</div>\n"; }	
}

?>